import axios from 'axios'
import qs from 'qs'

const instance = axios.create({
    baseURL: 'https://applet.deweiyi.com',
    // baseURL: 'http://192.168.0.12:81',
    responseType: 'json',
    timeout: 8000
})

// params 自定义axios get参数
export const get = (url, params) => {
    let obj = {
        validateStatus: status => status < 500
    }
    return instance.get(url, Object.assign(obj, params))
}

// post data 数据
export const post = (url, data) => {
    return instance.post(url, data)
}

// post 表单 data 数据
export const postForm = (url, data) => {
    let params = qs.stringify(data, { arrayFormat: 'repeat' })
    return instance.post(url, params)
}

// 发送文件
export const postFile = (url, param) => {
    return instance.post(url, param,{
		headers: {'Content-Type': 'multipart/form-data'}
	})
}
